package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.FileUploadService;
import com.atguigu.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "上传管理接口")
@RestController
@RequestMapping("api/album")
public class FileUploadApiController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 文件上传
     *
     * @return 上传后文件在线地址
     */
    @Operation(summary = "文件上传")
    @PostMapping("/fileUpload")
    //@RequestParam注解的作用：将方法上的参数绑定到controller层中。
    public Result<String> fileUpload(@RequestParam("file") MultipartFile file) {
        String address = fileUploadService.fileUpload(file);
        return Result.ok(address);

    }

}
